/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package edu.uts.reekie.designer.conceptual.edit;

import org.eclipse.gef.Request;
import org.eclipse.gef.commands.*;
import org.eclipse.gef.requests.*;

import edu.uts.reekie.designer.actions.SetConnectorDirectionAction;
import edu.uts.reekie.designer.conceptual.model.*;
import edu.uts.reekie.designer.model.commands.*;


/*
 * 
 * TODO: refactor to make view agnostic -- if possible
 */
public class ConnectorEditPolicy
	extends org.eclipse.gef.editpolicies.ConnectionEditPolicy
{
	
	
public Command getCommand(Request request){
	// Check for change of direction
	if (request.getType()==SetConnectorDirectionAction.BIDIRECTIONAL){
		SetConnectorDirectionCommand c = new SetConnectorDirectionCommand(Connector.BIDIRECTIONAL_CONNECTION);
		c.setConnector((Connector)getHost().getModel());
		return c;
	} else if (request.getType()==SetConnectorDirectionAction.UNIDIRECTIONAL) {
		SetConnectorDirectionCommand c = new SetConnectorDirectionCommand(Connector.UNIDIRECTIONAL_CONNECTION);
		c.setConnector((Connector)getHost().getModel());
		return c;	
	}
	return super.getCommand(request);
}

protected Command getDeleteCommand(GroupRequest request) {
	OldConnectionCommand c = new OldConnectionCommand();
	c.setConnector((Connector)getHost().getModel());
	return c;
}

}
